<?php

namespace App\Model;
/**
 * lzy
 * Class AuthRule
 * @package App\Model
 */
class  AuthGroupAccess extends BaseModel
{
    /**
     * @return AuthGroup
     */
    public function getAuthGroupModel()
    {
        return new  AuthGroup();
    }

    /**
     * 获取组
     * @param $uid
     * @return \App\Utility\Pool\MysqlObject|mixed
     * @throws \EasySwoole\Mysqli\Exceptions\ConnectFail
     * @throws \EasySwoole\Mysqli\Exceptions\JoinFail
     * @throws \EasySwoole\Mysqli\Exceptions\PrepareQueryFail
     * @throws \Throwable
     */
    public function getGroups($uid)
    {
        $condition = ['where' => [['uid', $uid, '=']]];
        return $this->getJoinLeft($condition,$this->getAuthGroupModel()->table,$this->table.'.group_id='.$this->getAuthGroupModel()->table.'.id');
    }

    /**
     *  获取权限名称
     * @return mixed
     */
    public function getAuthName($uid){
        return $this->leftJoin($this->getAuthGroupModel()->table.' a',$this->table.'.group_id=a.id')->getFiledValue(['uid'=>$uid],'title');
    }
}